# Author:Nana
# week07

names = ["nike","lily","jan","jack"]

# 2.3 删除列表(清空)
names.clear()
print(names)


numbers_dan=["1","3","5","7"]
numbers_shuang=["2","4","6","8"]

# 2.4 合并列表 .extend()  有先后顺序 （）内排在后面
# numbers_dan.extend(numbers_shuang)
# print(numbers_dan)

# 2.5 copy 复制列表

# 赋值 不等于真正意义的复制
# numbers_dan复制=numbers_dan
# print(numbers_dan)
# print(numbers_dan复制)
# numbers_dan.append("11")
# print("number_dan",numbers_dan)
# print("number_dan复制:",numbers_dan复制)

# 引入copy（）
# numbers_dan_数据备份=numbers_dan.copy()
# print(numbers_dan)
# print(numbers_dan_数据备份)
# numbers_dan.append("11")
# print("number_dan",numbers_dan)
# print("number_dan_copy:",numbers_dan_数据备份)

# 用切片[:] 等价于 copy()方法
numbers_dan_数据备份=numbers_dan[:]
print(numbers_dan)
print(numbers_dan_数据备份)
numbers_dan.append("11")
print("number_dan",numbers_dan)
print("number_dan_数据备份:",numbers_dan_数据备份)

# 2.6 .count()查看元素出现的次数/统计数量
stu_id = [90,96,90,89,99,79]


# 2.7 sort()排序 默认 从低到高 ; reverse=true 则从高到低
stu_id.sort()
print(stu_id)

stu_id.sort(reverse = True)
print(stu_id)

# sort() 排列字符串：按照首字母A-Z的顺序

# 2.8 课本练习
phrase = "Don't panic！"
plist = list(phrase)  # 字符串转变为list ;将元素合并为字符串.join()
print(phrase)
print(plist)
for i in range(4): # 删除后四位
    plist.pop()
print(plist)
plist.pop(0)
print(plist)
plist.remove("'")
print(plist)